package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.*;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcMtlCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-补单暂收入库")
@Slf4j
@RoleCheck(prgIds = {"160102"})
public class PcMtlSpController {
    @Autowired
    IPcMtlCheckService disService;

    private final int slipType = 1;

    @PutMapping("/getPurSpUnSentQuery")
    @ApiOperation(value = "订购未收查询-分页可条件查询",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo getPurSpUnSentQuery(@RequestBody MpPurDisRequest request){
        return disService.getPurUnSentQuery(request,slipType);
    }

    @PutMapping("/getPurSpSentQuery")
    @ApiOperation(value = "订购已收查询-分页可条件查询",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo getPurSpSentQuery(@RequestBody MpPurDisRequest request){
        return disService.getPurSentQuery(request,slipType);
    }

    @PutMapping("/sentSpMtlTypeQuery")
    @ApiOperation(value = "分类定义-查询",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo sentSpMtlTypeQuery(){
        return disService.sentMtlTypeQuery();
    }

    @PutMapping("/purSpSentAdd")
    @ApiOperation(value = "暂收入库-新增",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purSpSentAdd(@RequestBody List<AddPurSendRequest> request,
                                     @RequestParam@ApiParam(value = "厂商名称") String vendorNo,
                                     @RequestParam@ApiParam(value = "送货单号") String sendNo){
        return disService.purSentAdd(request,vendorNo,sendNo, slipType);
    }

    @PutMapping("/sentSpMtlTypeAdd")
    @ApiOperation(value = "分类定义-增删",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo sentSpMtlTypeAdd(@RequestBody List<UserMtlTypeRequest> requests,
                                       @RequestParam @ApiParam("标志位（1.选择分类 2.还原分类）") Integer flag){
        return disService.sentMtlTypeAdd(requests,flag);
    }

//    @PutMapping("/purStockAdd")
//    @ApiOperation(value = "补单暂收入库-转入仓库-新增",tags = "仓储部-仓储工厂作业-补单暂收入库")
//    public ResponseInfo purStockAdd(@RequestBody List<AddPurSentRequest> request){
//        return disService.purStockAdd(request);
//    }

    @PutMapping("/purPutSpStockUpdate")
    @ApiOperation(value = "入库批处理-修改",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purPutSpStockUpdate(@RequestBody List<PurSentRequest> request){
        return disService.purPutStockUpdate(request);
    }

    @PutMapping("/purSpSentRemark")
    @ApiOperation(value = "写入备注-修改",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purSpSentRemark(@RequestBody List<PurSentRemarkRequest> request){
        return disService.purSentRemark(request);
    }

    @GetMapping("/purSpStockUpdate")
    @ApiOperation(value = "转入仓库-修改",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purSpStockUpdate(@RequestParam String recNo){
        return disService.purStockUpdate(recNo);
    }

    @PostMapping("/purSpSentDelete")
    @ApiOperation(value = "修改-删除",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purSpSentDelete(@RequestParam String primaryId){
        disService.purSpSentDelete(primaryId,slipType);
        return ResponseInfo.ok();
    }

    @GetMapping("/purSpStockBack")
    @ApiOperation(value = "厂商，分类-回显",tags = "仓储部-仓储工厂作业-补单暂收入库")
    public ResponseInfo purSpStockBack(){
        return disService.purStockBack();
    }

}
